<?php
/**
 * Helper for interacting with Visi_Controller_Plugin_Acl
 *
 * @package     Visi
 * @subpackage  Action Helpers
 * @author      Luke Visinoni <luke.visinoni@gmail.com>
 * @copyright   (c) 2011 Luke Visinoni <luke.visinoni@gmail.com>
 * @version     $Id$
 */
class Visi_Controller_Action_Helper_Acl extends Zend_Controller_Action_Helper_Abstract {

    protected $_aclPlugin;

    /**
     * Constructor
     *
     * @return void
     **/
    function __construct()
    {
        $this->_aclPlugin = $this->getAclPlugin();
    }

    /**
     * Returns the Acl Plugin object
     *
     * @return Visi_Controller_Plugin_Acl
     **/
    public function getAclPlugin()
    {
        if (null === $this->_aclPlugin) {
            $front = Zend_Controller_Front::getInstance();
            if ($front->hasPlugin('Visi_Controller_Plugin_Acl')) {
                $this->_aclPlugin = $front->getPlugin('Visi_Controller_Plugin_Acl');
            } else {
                $front->registerPlugin(new Visi_Controller_Plugin_Acl());
                $this->_aclPlugin = $this->getAclPlugin();
            }
        }

        return $this->_aclPlugin;
    }

    /**
     * Call the denyAccess function of the Acl Plugin object
     *
     * @return void
     **/
    public function denyAccess()
    {
        $this->_aclPlugin->denyAccess();
    }
}